package com.livideo.baseutilslibrary.utils;



import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.lang.reflect.Type;

public class JsonBeanTrans {

	/**
	  * 序列化方法
	  */
	 public static String bean2json(Object bean, Type c) {
		GsonBuilder builder = new GsonBuilder();
		Gson gson=	builder.create();
	    return gson.toJson(bean,c);
	 }

	 /**
	  * 反序列化方法
	  */
	 @SuppressWarnings("unchecked")
	 public static <T> T json2bean(String json, Type c) {
		  Gson gson = new Gson();
	      return (T) gson.fromJson(json,  c);
	 }



}
